<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>试卷管理</title>
    <link rel="shortcut icon" href="../../static/favicon.ico"
          th:href="@{/static/favicon.ico}">
    <link href="../../static/css/bootstrap.min.css?v=3.3.6" rel="stylesheet"
          th:href="@{/static/css/bootstrap.min.css(v=3.3.6) }">
    <link href="../../static/css/font-awesome.css?v=4.4.0" rel="stylesheet"
          th:href="@{/static/css/font-awesome.css(v=4.4.0) }">
    <link href="../../static/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"
          th:href="@{/static/css/plugins/bootstrap-table/bootstrap-table.min.css }">
    <link href="../../static/css/animate.css" rel="stylesheet"
          th:href="@{/static/css/animate.css }">
    <link href="../../static/css/style.css?v=4.1.0" rel="stylesheet"
          th:href="@{/static/css/style.css(v=4.1.0) }">
    <!--Bootstrap表格插件-->
    <link href="../../static/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"
          th:href="@{/static/css/plugins/bootstrap-table/bootstrap-table.min.css }">
    <!--滑动按钮-->
    <link href="../../static/css/plugins/switchery/switchery.css"
          th:href="@{/static/css/plugins/switchery/switchery.css}" rel="stylesheet">
    <!--章节插件-->
    <link rel="stylesheet" href="../../static/public/exam/jquery-collapse/css/jquery.collapse.css"
          th:href="@{/static/public/exam/jquery-collapse/css/jquery.collapse.css}">
    <!-- 弹出框插件 -->
    <link href="../../static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet"
          th:href="@{/static/css/plugins/sweetalert/sweetalert.css }">
    <style type="text/css">
        body {
            word-break: break-all;
        }

        /* 表格样式 */
        .table > thead > tr > th {
            text-align: center;
            color: #2a62bc;
        }

        .table > tbody > tr > td {
            text-align: center;
        }

        #paperManagementForm .col-md-2 {
            padding-left: 0px;
            padding-right: 8px;
        }
    </style>
</head>
<body class="gray-bg" style="padding: 0px !important;">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox-title">
        <div class="row row-lg">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active" id="allStu"><a data-toggle="tab" href="#tab-1" aria-expanded="true">我的试卷</a>
                        </li>
                        <li class="" id="notAllStu"><a data-toggle="tab" href="#tab-2" aria-expanded="false">共享试卷</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="tab-1" class="tab-pane active">
                            <div class="panel-body">
                                <p style="color: #aaa">试卷用于组织考试，由试题或试题生成规则组成，请在以下列表中管理您的试卷</p>
                                <!--创建试卷、试卷管理按钮-->
                                <div>
                                    <div class="btn-group" role="group">
                                        <button type="button" class="btn btn-white dropdown-toggle"
                                                data-toggle="dropdown" title="创建试卷">
                                            创建试卷 <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu">
                                            <li id="commonTestPaper" onclick="switchover(1)"><a href="#"><i
                                                    class="glyphicon glyphicon-tasks"></i>&nbsp;&nbsp; 创建普通试题</a>
                                            </li>
                                            <li id="randomTestPaper" onclick="switchover(2)"><a href="#"><i
                                                    class="glyphicon glyphicon-random"></i>&nbsp;&nbsp;&nbsp;创建随机试题</a>
                                            </li>
                                        </ul>
                                    </div>
                                    <button type="button" class="btn btn-success" title="试卷管理">试卷管理</button>
                                </div><!--END---创建试卷、试卷管理按钮-->
                                <!--创建试题-->
                                <div id="createTestPaper" class="panel panel-default"
                                     style="margin-top: 10px;display: none">
                                    <div class="panel-heading">
                                        <h4 id="createPaperTitles"> 创建普通试卷&nbsp;&nbsp;&nbsp;
                                            <small style="font-size: 13px;">每个考生的试卷为相同试题，试题在考试时可随机排序显示</small></h4>
                                    </div>
                                    <div class="panel-body">
                                        <form method="get" class="form-horizontal col-md-12 createTestPaper"
                                              id="createTestPaper_1">
                                            <input type="text" id="paperId" style="display: none">
                                            <!--试卷名称-->
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">
                                                    试卷名称</label>
                                                <div class="col-sm-8">
                                                    <input type="text" name="testPaperName_1" class="form-control">
                                                </div>
                                            </div>
                                            <!--试卷分类-->
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">
                                                    试卷分类</label>
                                                <div class="col-sm-8">
                                                    <div class="input-group">
                                                        <input type="text" name="classification"
                                                               class="form-control classification"
                                                               placeholder="分类">
                                                        <div class="input-group-btn">
                                                            <button type="button" class="btn btn-success">
                                                                <i class="glyphicon glyphicon-plus"></i>
                                                            </button>
                                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <!--试卷状态-->
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">
                                                    试卷状态</label>
                                                <div class="col-sm-8">
                                                    <input type="checkbox" name="startUsing"
                                                           class="js-switch-notable form-control"/>
                                                </div>
                                            </div>
                                            <!--管理权限-->
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">
                                                    管理权限 </label>
                                                <div class="col-sm-8">
                                                    <div class="input-group">
                                                        <input type="text" name="adminPermissions"
                                                               class="form-control adminPermissions "
                                                               placeholder="权限">
                                                        <div class="input-group-btn">
                                                            <button type="button" class="btn btn-white dropdown-toggle"
                                                                    data-toggle="dropdown">
                                                                <span class="caret"></span>
                                                            </button>
                                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <!--试卷总分-->
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">
                                                    试卷总分</label>
                                                <div class="col-sm-8">
                                                    <input type="text" name="totalScore" disabled=""
                                                           class="form-control "
                                                           placeholder="无需填写,将自动计算,将自动填值">
                                                </div>
                                            </div>
                                            <!--章节设置-->
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">
                                                    试题设置</label>
                                                <div class="col-sm-8">
                                                    <button type="button" class="btn btn-white text-sm"
                                                            style="margin-bottom: 15px"
                                                            id="add_section_btn"><i
                                                            class="glyphicon glyphicon-plus addSection"></i>&nbsp;添加试题
                                                    </button>
                                                    <!--章节内容-->
                                                    <!-- 折叠面板组 -->
                                                    <div>
                                                        <div class="panel-group" id="accordion" role="tablist"
                                                             aria-multiselectable="true">
                                                            <!-- 在点击增加章节时，来clone此元素，并追加到 父元素中 -->
                                                            <div class="panel panel-default" panel_sign="0">
                                                                <!-- 一组章节 -->
                                                                <div class="panel-heading blue-bg" role="tab">
                                                                    <h4 class="panel-title">
                                                                        <!-- 在右上角添加关闭小图标 -->
                                                                        <button type="button" class="close"
                                                                                onclick="deleteAllTopic(this)"
                                                                                data-dismiss="close">
                                                                            <span>&times;</span>
                                                                        </button>
                                                                        <!-- 添加向下的小图标 caret -->
                                                                        <a role="button" class="pull-right right_caret"
                                                                           data-toggle="collapse" href="#collapseOne">
                                                                            <span class="caret"></span>
                                                                        </a>
                                                                        <!-- 增加试题按钮 -->
                                                                        <button type="button"
                                                                                class="btn btn-default btn-xs pull-right right_caret addTopic"
                                                                                onclick="addTopic(this)"
                                                                                data-toggle="modal">
                                                                            <span class="glyphicon glyphicon-plus">增加试题</span>
                                                                        </button>

                                                                        <!-- 输入项: 章节名称 -->
                                                                        <div class="input_field">
                                                                            <label>大题名称：</label>
                                                                            <input type="text" name="sectionName"
                                                                                   class="input"/>
                                                                        </div>

                                                                    </h4>
                                                                </div>
                                                                <!-- 要重写包一层 panel-heading -->
                                                                <div class="panel-heading gray-bg">
                                                                    <h4 class="panel-title">
                                                                        <!-- 输入项：章节描述 -->
                                                                        <div class="input_field">
                                                                            <label class="text-muted">大题描述：</label>
                                                                            <input type="text" name="sectionDescription"
                                                                                   class="input"/>
                                                                            <!-- 批量设置分值: 这里修改padding，是为了改写 btn-xs的默认样式 -->
                                                                            <a
                                                                                    class="btn btn-info btn-xs pull-right"
                                                                                    onclick="volumeSetScore(this)"
                                                                                    data-trigger="setScore">批量设置</a>
                                                                            <input type="text" name="scoreForEach"
                                                                                   class="input_score pull-right"
                                                                                   placeholder="分值"/>
                                                                        </div>
                                                                    </h4>
                                                                </div>
                                                                <!-- 内容区 -->
                                                                <div id="collapseOne" class="panel-collapse collapse in"
                                                                     role="tabpanel">
                                                                    <div class="panel-body">
                                                                    </div>
                                                                </div> <!-- end of 内容区 -->
                                                            </div><!-- end of panel -->
                                                        </div>
                                                    </div>
                                                    <!-- end of panel-group --> <!--END--章节内容-->
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                    <!--提交和重新填写的两个按钮-->
                                    <div class="col-md-offset-6" style="padding: 10px">
                                        <button type="button" class="btn btn-success add" id="addBtn">添加试卷</button>
                                        <button type="button" class="btn btn-success add" id="alertBtn"
                                                style="display: none">修改试卷
                                        </button>
                                        <button type="button" class="btn btn-danger reset">重新填写</button>
                                    </div>
                                    <!--END--提交和重新填写的两个按钮-->
                                </div><!--END---创建试题-->
                                <!--题库管理-->
                                <div id="topicManagement">
                                    <!--右上角form表单-->
                                    <div id="toolbar">
                                        <form class="form-inline" id="paperManagementForm">
                                            <!-- 试卷名称-->
                                            <div class="col-md-2">
                                                <div class="form-group">
                                                    <div class="input-group ">
                                                        <input type="text" name="testPaperName"
                                                               class="form-control testPaperName"
                                                               placeholder="试卷名称">
                                                        <div class="input-group-btn">
                                                            <button type="button" class="btn btn-white dropdown-toggle"
                                                                    data-toggle="dropdown">
                                                                <span class="caret"></span>
                                                            </button>
                                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <!--状态-->
                                            <div class="col-md-2">
                                                <div class="form-group">
                                                    <div class="input-group ">
                                                        <input type="text" name="state" class="form-control state"
                                                               placeholder="状态">
                                                        <div class="input-group-btn">
                                                            <button type="button" class="btn btn-white dropdown-toggle"
                                                                    data-toggle="dropdown">
                                                                <span class="caret"></span>
                                                            </button>
                                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <!--分类-->
                                            <div class="col-md-2">
                                                <div class="form-group ">
                                                    <div class="input-group">
                                                        <input type="text" name="classification"
                                                               class="form-control classification"
                                                               placeholder="分类">
                                                        <div class="input-group-btn">
                                                            <button type="button" class="btn btn-white dropdown-toggle"
                                                                    data-toggle="dropdown">
                                                                <span class="caret"></span>
                                                            </button>
                                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <!--类型-->
                                            <div class="col-md-2">
                                                <div class="form-group ">
                                                    <div class="input-group">
                                                        <input type="text" name="type" class="form-control type"
                                                               placeholder="类型">
                                                        <div class="input-group-btn">
                                                            <button type="button" class="btn btn-white dropdown-toggle"
                                                                    data-toggle="dropdown">
                                                                <span class="caret"></span>
                                                            </button>
                                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <!--权限-->
                                            <div class="col-md-2">
                                                <div class="form-group ">
                                                    <div class="input-group">
                                                        <input type="text" name="adminPermissions"
                                                               class="form-control adminPermissions"
                                                               placeholder="权限">
                                                        <div class="input-group-btn">
                                                            <button type="button" class="btn btn-white dropdown-toggle"
                                                                    data-toggle="dropdown">
                                                                <span class="caret"></span>
                                                            </button>
                                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <!--查询按钮-->
                                            <button class="btn btn-success query" type="button">搜索</button>
                                        </form>
                                    </div><!--END--右上角form表单-->
                                    <table class="tb_departments"></table>
                                </div> <!--END---题库管理-->
                            </div>

                        </div>
                        <div id="tab-2" class="tab-pane">
                            <div class="panel-body">
                                <p style="color: #aaa">共享试卷是由各管理员创建并 共享 给所有管理员使用的试卷，您可以使用这些试卷组织考试</p>
                                <!--右上角form表单-->
                                <div id="toolbar_1">
                                    <form class="form-inline" id="shareTestPaperFrom">
                                        <!-- 试卷名称-->
                                        <div class="form-group">
                                            <div class="input-group ">
                                                <input type="text" name="testPaperName"
                                                       class="form-control testPaperName"
                                                       placeholder="试卷名称">
                                                <div class="input-group-btn">
                                                    <button type="button" class="btn btn-white dropdown-toggle"
                                                            data-toggle="dropdown">
                                                        <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                        <!--类型-->
                                        <div class="form-group ">
                                            <div class="input-group">
                                                <input type="text" name="classification"
                                                       class="form-control classification"
                                                       placeholder="分类">
                                                <div class="input-group-btn">
                                                    <button type="button" class="btn btn-white dropdown-toggle"
                                                            data-toggle="dropdown">
                                                        <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                        <!--创建人-->
                                        <div class="form-group ">
                                            <input type="text" name="founder"
                                                   class="form-control founder"
                                                   placeholder="创建人">
                                        </div>
                                        <!--查询按钮-->
                                        <button class="btn btn-success query" type="button">搜索</button>
                                    </form>
                                </div><!--END--右上角form表单-->
                                <table class="tb_departments_1"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--查看的模态框-->
<div class="modal  fade" id="modal_1" tabindex="-1" role="dialog">
    <div class="modal-dialog  modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title">试卷预览</h4>
            </div>
            <div class="modal-body">
                <form method="get" class="form-horizontal" id="form_toView">
                    <div class="form-group">
                        <label class="col-sm-2 control-label ">
                            试卷名称</label>
                        <div class="col-sm-8">
                            <input type="text" name="testPaperName" disabled="" class="form-control testPaperName_1"
                                   placeholder="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">
                            试卷状态</label>
                        <div class="col-sm-8">
                            <input type="text" name="state" disabled="" class="form-control state_1 " placeholder="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">
                            管理权限</label>
                        <div class="col-sm-8">
                            <input type="text" name="adminPermissions" disabled=""
                                   class="form-control adminPermissions_1" placeholder="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">
                            试卷总分</label>
                        <div class="col-sm-8">
                            <input type="text" name="totalScore" disabled="" class="form-control totalScore"
                                   placeholder="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">
                            章节设置</label>
                    </div>
                    <div class="form-group">
                        <div id="content"></div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-success" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<!--关联考试的模态框-->
<div class="modal  fade" id="modal_2" tabindex="-1" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title">关联的考试</h4>
            </div>
            <div class="modal-body">
                <p style="color: #aaa">试卷&nbsp;<a class="testPaperName_2"></a>&nbsp;被如下列表中的考试所引用</p>
                <table class="tb_departments_2"></table>
            </div>
        </div>
    </div>
</div>
<!-- 章节设置里的模态框 -->
<div class="modal fade" id="modal_4" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">选择题库</h4>
            </div>
            <div class="modal-body">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active"><a data-toggle="tab" href="#tab-myTopic" aria-expanded="true">我的试题</a>
                        </li>
                        <li class=""><a data-toggle="tab" href="#tab-shareTopic" aria-expanded="false">共享试题</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="tab-myTopic" class="tab-pane active">
                            <div class="panel-body">
                                <p>我的试题信息如下,请勾选考试试题</p>
                                <table class="tb_departments_3"></table>
                            </div>
                        </div>
                        <div id="tab-shareTopic" class="tab-pane">
                            <div class="panel-body">
                                <p>共享试题信息如下,请勾选考试试题</p>
                                <table class="tb_departments_4"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="myModalBatchAddBtn" data-dismiss="modal">批量插入</button>
            </div>
        </div>
    </div>
</div>
<!--试题预览的模态框-->
<div class="modal  fade  bs-example-modal-lg" id="modal_3" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title">试题预览</h4>
            </div>
            <div class="modal-body">
                <p style="color: #aaa">以下为该试题的详细信息</p>
                <table class="table table-bordered" style="margin-top: 10px">
                    <tr>
                        <td style="background: #e6e6e6">试题类型</td>
                        <td><a name="typeName"></a>
                        </td>
                    </tr>
                    <tr>
                        <td style="background: #e6e6e6">试题难度</td>
                        <td><a name="hardLevel"></a></td>
                    </tr>
                    <tr>
                        <td style="background: #e6e6e6">所属题库</td>
                        <td><a name="examBankName"></a></td>
                    </tr>
                    <tr>
                        <td style="background: #e6e6e6">试题标签</td>
                        <td><a name="lable"></a></td>
                    </tr>
                    <tr>
                        <td style="background: #e6e6e6">试题状态</td>
                        <td><a name="status"></a></td>
                    </tr>
                    <tr>
                        <td style="background: #e6e6e6">试题题干</td>
                        <td><a name="quesContent"></a></td>
                    </tr>
                    <tr>
                        <td style="background: #e6e6e6">参考答案</td>
                        <td><a name="correctAnswer"></a></td>
                    </tr>
                    <tr>
                        <td style="background: #e6e6e6">答案解析</td>
                        <td><a name="analyze"></a></td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>
<!--章节设置里试题展示的样式-->
<div class="col-md-12 testQuestions" style="display: none;margin: 5px">
    <div class="col-md-2"
         style="margin: 0;padding: 0;">
        <input type="number" min="0" class="form-control" value="1"
               onchange="setOneScore(this)"
               name="score" style=" background: #ffc">
    </div>
    <div class="col-md-10"
         style="margin: 0;padding: 0">
        <div class="input-group">
            <input type="text"
                   class="form-control" disabled="disabled"
                   name="topicName"
                   style="white-space: nowrap;text-overflow: ellipsis;overflow: hidden;">
            <div class="input-group-btn">
                <button type="button"
                        class="btn btn-info" onclick="previewTopic_1(this)">详情
                </button>
                <button type="button"
                        class="btn btn-danger" onclick="deleteOneTopic(this)">删除
                </button>
            </div>
        </div>
    </div>
</div>
<!--章节插件的样式-->
<div class="panel panel-default" panel_sign="0" style="display: none">
    <!-- 一组章节 -->
    <div class="panel-heading blue-bg" role="tab">
        <h4 class="panel-title">
            <!-- 在右上角添加关闭小图标 -->
            <button type="button" class="close"
                    onclick="deleteAllTopic(this)"
                    data-dismiss="close">
                <span>&times;</span>
            </button>
            <!-- 添加向下的小图标 caret -->
            <a role="button" class="pull-right right_caret"
               data-toggle="collapse" href="#collapseOne">
                <span class="caret"></span>
            </a>
            <!-- 增加试题按钮 -->
            <button type="button"
                    class="btn btn-default btn-xs pull-right right_caret addTopic"
                    onclick="addTopic(this)"
                    data-toggle="modal">
                <span class="glyphicon glyphicon-plus">增加试题</span>
            </button>

            <!-- 输入项: 章节名称 -->
            <div class="input_field">
                <label>大题名称：</label>
                <input type="text" name="sectionName"
                       class="input"/>
            </div>

        </h4>
    </div>
    <!-- 要重写包一层 panel-heading -->
    <div class="panel-heading gray-bg">
        <h4 class="panel-title">
            <!-- 输入项：章节描述 -->
            <div class="input_field">
                <label class="text-muted">大题描述：</label>
                <input type="text" name="sectionDescription"
                       class="input"/>
                <!-- 批量设置分值: 这里修改padding，是为了改写 btn-xs的默认样式 -->
                <a onclick="volumeSetScore(this)"
                   class="btn btn-info btn-xs pull-right"
                   data-trigger="setScore">批量设置</a>
                <input type="text" name="scoreForEach"
                       class="input_score pull-right"
                       placeholder="分值"/>
            </div>
        </h4>
    </div>
    <!-- 内容区 -->
    <div class="panel-collapse collapse in"
         role="tabpanel">
        <div class="panel-body">
        </div>
    </div> <!-- end of 内容区 -->
</div>
</body>
<!-- 全局js -->
<script src="../../static/js/jquery.min.js?v=2.1.4"
        th:src="@{/static/js/jquery.min.js(v=2.1.4) }"></script>
<script src="../../static/js/bootstrap.min.js?v=3.3.6"
        th:src="@{/static/js/bootstrap.min.js(v=3.3.6) }"></script>
<!-- 自定义js -->
<script src="../../static/js/content.js?v=1.0.0"
        th:src="@{/static/js/content.js(v=1.0.0) }"></script>
<!--Bootstrap表格插件 -->
<script src="../../static/js/plugins/bootstrap-table/bootstrap-table.min.js"
        th:src="@{/static/js/plugins/bootstrap-table/bootstrap-table.min.js }"></script>
<script src="../../static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"
        th:src="@{/static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js }"></script>
<script src="../../static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"
        th:src="@{/static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js }"></script>
<!--滑动按钮-->
<script src="../../static/js/plugins/switchery/switchery.js"
        th:src="@{/static/js/plugins/switchery/switchery.js}"></script>
<!--动态搜索-->
<script src="../../static/js/plugins/suggest/bootstrap-suggest.min.js"
        th:src="@{/static/js/plugins/suggest/bootstrap-suggest.min.js}"></script>
<script src="../../static/public/user/bsSuggest.js"
        th:src="@{/static/public/user/bsSuggest.js }"></script>
<!--章节插件-->
<!--<script src="../../static/public/exam/jquery-collapse/js/jquery.collapse.js"
        th:src="@{/static/public/exam/jquery-collapse/js/jquery.collapse.js }"></script>-->
<!-- 弹出框插件 -->
<script src="../../static/js/plugins/sweetalert/sweetalert.min.js"
        th:src="@{/static/js/plugins/sweetalert/sweetalert.min.js }"></script>
<!--自定义js---表格操作-->
<script src="../../static/public/exam/tableOperation.js"
        th:src="@{/static/public/exam/tableOperation.js}"></script>
<!--滑动按钮初始化、创建试卷按钮监听、文章内容-->
<script>
    $(function () {
        switchForNoTable();
    });
    let checked_notable = false;
    let switchery_NoTable;

    /* 初始化非表格中的滑动按钮状态*/
    function switchForNoTable() {
        let elems = Array.prototype.slice.call($('.js-switch-notable'));
        elems.forEach(function (html) {
            /* size: 'normal' 控制大小*/
            switchery_NoTable = new Switchery(html);
            html.onchange = function () {
                checked_notable = html.checked;
            }
        });
    }

    $('#tab-1 button[title="试卷管理"]').click(function () {
        $('#topicManagement').fadeIn(1500);
        $('#createTestPaper').fadeOut(500);
        $('#tab-1 button[title="试卷管理"]').attr('class', 'btn btn-success dropdown-toggle')
        $('#tab-1 button[title="创建试卷"]').attr('class', 'btn btn-white dropdown-toggle')
        //清空章节内容
        let clone = $('div[panel_sign="0"]:last').clone().css('display', 'block');
        $('#accordion').empty();
        $('#accordion').append(clone);
        panel_sign = 0;
        submitAllChapterData.clear()
        panelMap.clear()
        panelEventMap.clear()
    });
</script>
<!-- 文章内容 -->
<script>
    //定义一个用于最后提交的数据集合  map<id,数据对象集合>
    let submitAllChapterData = new Map();
    /**************************************************************添加章节-克隆操作*/
        //标记
    let panel_sign = 0;
    //定义一个存储章节组件的集合
    let panelEventMap = new Map();
    panelEventMap.set(0, $('div[panel_sign=0]'));
    $('#add_section_btn').click(function () {
        clonePanel();
    });

    function clonePanel() {
        //获取最外层
        let accordion = $('#accordion');
        //选出第一个章节组件，进行拷贝复制,给定唯一id,方便后期进行储存到数组中去
        let newPanel = $(".panel.panel-default", accordion).eq(0).clone().attr('panel_sign', ++panel_sign);
        //修改此元素中的 <a> 中的id值以及 内容区的id
        let target = guid();
        //修改下拉小按钮的 href值，保证与 下面的 panel-collapse中的id值一样
        $("a", newPanel).attr("href", "#" + target);
        $(".panel-collapse", newPanel).attr("id", target);
        //把复制出来的元素中的 panel-body 元素清空
        $(".panel-body", newPanel).children().remove();
        //再把这个复制出来的元素添加到父元素中
        accordion.append(newPanel);
        //将克隆好的新章节事件添加到集合
        panelEventMap.set(panel_sign, newPanel);
    }

    /**************************************************************添加试题*/
        //定义一个集合，用来存储选出来的对象
    let panelMap = new Map();
    //初始化模态框中的表格数据
    //我的试题
    let myTopicData = [{
        checkbox: true,
    }, {
        field: 'examBankName',
        title: '题库',
    }, {
        field: 'typeName',
        title: '类型',
    }, {
        field: 'hardLevel',
        title: '难度',
    }, {
        field: 'quesContent',
        title: '题干',
    }, {
        field: 'userName',
        title: '创建人',
    }, {
        field: 'operate',
        title: '操作',
        formatter: function (value, row, index) {
            return [
                '<button type="button" class="btn btn-md  btn-white preview data-dismiss="modal"><i class="fa fa-eye"/></button>',
            ].join("");
        },
        events: {
            'click .preview': function (e, value, row, index) {
                previewTopic(row);
            }
        }
    }];
    createTable('.tb_departments_3', '/owep/examQues/quesList', "", true, myTopicData, 'get')
    //共享试题
    createTable('.tb_departments_4', '/owep/examQues/shareExamQues', "", true, myTopicData, 'get')

    //监听添加试题按钮
    function addTopic(event) {
        //获取当前是哪个章节事件中的模态框
        let id = $(event).parents('.panel .panel-default').attr('panel_sign');
        //打开模态框
        $('#modal_4').attr('panel_sign', id).modal();
        //回显模态框的数据
        echoPanelBodyData(id)
    };

    //回显模态框中的数据
    function echoPanelBodyData(id) {
        //清空表格勾选的记录
        $('.tb_departments_3  input[name="btSelectItem"]').removeAttr("disabled");
        $('.tb_departments_3').bootstrapTable('uncheckAll');
        $('.tb_departments_4  input[name="btSelectItem"]').removeAttr("disabled");
        $('.tb_departments_4').bootstrapTable('uncheckAll');
        //迭代数据进行勾选
        submitAllChapterData.has(id) ?
            submitAllChapterData.get(id).forEach(function (item, id) {

                if (item.myTopicOrShareTop == "myTopic") {
                    $('.tb_departments_3').bootstrapTable('checkBy', {field: 'id', values: [item["testQuestionsId"]]});
                    $('.tb_departments_3 .selected input[name="btSelectItem"]').attr("disabled", "true");
                } else {
                    $('.tb_departments_4').bootstrapTable('checkBy', {field: 'id', values: [item["testQuestionsId"]]});
                    $('.tb_departments_4 .selected input[name="btSelectItem"]').attr("disabled", "true");
                }
            }) : "";
    }

    //批量插入
    $('#modal_4 #myModalBatchAddBtn').click(function () {
        //获勾选数据
        let myTopicChoice = $('.tb_departments_3').bootstrapTable('getAllSelections');
        let shareTopicChoice = $('.tb_departments_4').bootstrapTable('getAllSelections');
        myTopicChoice.forEach(function (item, index) {
            item.myTopicOrShareTop = "myTopic";
        })
        shareTopicChoice.forEach(function (item, index) {
            item.myTopicOrShareTop = "shareTopic";
            myTopicChoice.push(item);
        })
        //放入集合
        let id = $('#modal_4').attr('panel_sign');
        panelMap.set(id, myTopicChoice);
        //更新用于提交的数据
        submitAllChapter(panelMap);
        //遍历展示
        showChapterTopic(id, submitAllChapterData);
        getTotalPoints();
    });

    //总分
    function getTotalPoints() {
        let totalPoints = 0;
        submitAllChapterData.forEach(function (value, key) {

            value.forEach(function (item, index) {
                totalPoints = item["score"] * 1 + totalPoints;
            })
        })
        $('#createTestPaper input[name=totalScore]').val(totalPoints);
    }

    //遍历展示的方法
    function showChapterTopic(panel_sign, map) {
        //获取父级控件
        let event = $('#accordion div[panel_sign=' + panel_sign + ']').find('.panel-body');
        //清除已有的样式
        event.empty();
        //遍历展示样式
        map.get(panel_sign).forEach(function (item, index) {
            event.append($('.testQuestions:last').clone().css('display', 'block').attr('testQuestions', item["id"]));
            event.find('div[testQuestions=' + item["id"] + ']').find('input[name=score]').val(item["score"])
            event.find('div[testQuestions=' + item["id"] + ']').find('input[name=topicName]').val(item["title"])
        })
        //展示总分
        getTotalPoints();
    }

    //组装要提交数据的方法(最后使用)
    function submitAllChapter(map) {
        submitAllChapterData = new Map();
        map.forEach(function (value, key) {
            //定义一个用来存储id,题目，分数的集合
            let submitPaneBodyData = new Array();

            value.forEach(function (item, index) {
                let object = {
                    id: index,
                    testQuestionsId: item["id"],
                    score: 5,
                    title: item["quesContent"],

                    myTopicOrShareTop: item["myTopicOrShareTop"]
                }

                //存入要提交数据的对象集合
                submitPaneBodyData.push(object);
            });
            //过滤数据

            let percolatorData = new Set(submitPaneBodyData);
            submitPaneBodyData = new Array();
            percolatorData.forEach(function (item, index) {
                submitPaneBodyData.push(item);
            })
            //存入要提交的集合中去
            submitAllChapterData.set(key, submitPaneBodyData);

        });
    }

    //预览试题
    function previewTopic(row) {
        $('#modal_3 a[name=typeName]').text(row.typeName);
        $('#modal_3 a[name=hardLevel]').text(row.hardLevel);
        $('#modal_3 a[name=examBankName]').text(row.examBankName);
        $('#modal_3 a[name=lable]').text(row.lable);
        row.status == '1' ? $('#modal_3 a[name=status]').text("正常") : $('#modal_3 a[name=status]').text("禁用");
        $('#modal_3 a[name=quesContent]').text(row.quesContent);
        $('#modal_3 a[name=correctAnswer]').text(row.correctAnswer);
        $('#modal_3 a[name=analyze]').text(row.analyze);
        $('#modal_3').modal();
    }

    //外部试题的预览按钮的方法
    function previewTopic_1(event) {
        let panel_sign = $(event).parents('.panel .panel-default').attr('panel_sign')
        let id = $(event).parents('.testQuestions').attr('testQuestions');
        panelMap.forEach(function (value, key) {

        })

        let row = panelMap.get(panel_sign)[id];
        previewTopic(row)
    }

    /************************************************************关闭按钮-删除操作*/
    //外部删除按钮
    function deleteOneTopic(event) {
        let panel_sign = $(event).parents('.panel .panel-default').attr('panel_sign');
        let id = $(event).parents('.testQuestions').attr('testQuestions');
        $(event).parents('.testQuestions').remove();
        panelMap.get(panel_sign).splice(id, 1)
        submitAllChapterData.get(panel_sign).splice(id, 1);
        getTotalPoints()
        //将所删除小题下面小题的顺序上移
        $('.testQuestions').each(function(){
            let topId = $(this).parents('.panel .panel-default').attr('panel_sign');
            let quesId = $(this).attr('testQuestions');
            if(topId == panel_sign && quesId > id){
                $(this).attr('testQuestions',quesId-1);
            }
        })
    }

    //删除全部的按钮
    function deleteAllTopic(event) {
        let panel_sign = $(event).parents('.panel .panel-default').attr('panel_sign')
        if (panelEventMap.size == 1) {
            swal("删除失败！", "至少保留一章", "error");
        } else {
            $(event).parents('.panel .panel-default').remove();
            panelEventMap.delete(panel_sign - 1 + 1)
            panelMap.delete(panel_sign)
            submitAllChapterData.delete(panel_sign);
        }
        getTotalPoints()
    }

    /****************************************************分数设置*/
    //批量设置分数
    function volumeSetScore(event) {
        let panel_sign = $(event).parents('.panel .panel-default').attr('panel_sign');
        let volumeScore = $('#accordion div[panel_sign=' + panel_sign + '] input[name=scoreForEach]').val();
        $('#accordion div[panel_sign=' + panel_sign + '] .testQuestions input[name=score]').val(volumeScore);
        submitAllChapterData.get(panel_sign).forEach(function (item, index) {

            item["score"] = volumeScore;

        })
        getTotalPoints();
    }

    //单个修改分数
    function setOneScore(event) {
        let panel_sign = $(event).parents('.panel .panel-default').attr('panel_sign');
        let oneScore = $(event).parents('.testQuestions').attr('testquestions');

        submitAllChapterData.get(panel_sign)[oneScore]["score"] = $(event).val();
        getTotalPoints();
    }

    <!--表单、动态搜索初始化-->


    /*动态搜索初始化*/
    //名称
    //bsSuggest(".testPaperName", url, "testPaperName");
    //状态
    //bsSuggest(".state", url, "state");
    //分类
    $(".classification").bsSuggest({
        data: {
            "value": [
                {
                    "keyName": "统考"
                }, {
                    "keyName": "个人能力测试"
                }, {
                    "keyName": "政策"
                }
            ]
        }
    });
    //类型
    //bsSuggest(".type", url, 'type');
    //权限
    $(".adminPermissions").bsSuggest({
        data: {
            "value": [
                {
                    "keyName": "完全私有"
                }, {
                    "keyName": "只读共享"
                }
            ]
        }
    });

    /**************************************************表单********************************************/
    //我的试卷--试卷管理
    $('#paperManagementForm .query').click(function () {
        let dataList = new Array('testPaperName', 'state', 'classification', 'type', 'adminPermissions');
        queryRecords('#paperManagementForm', dataList);
    });
    //共享试卷
    $('#shareTestPaperFrom .query').click(function () {
        let dataList = new Array('testPaperName', 'classification', 'founder');
        queryRecords('#shareTestPaperFrom', dataList);
    });
    //创建试卷
    /*按钮切换*/
    function testPaper(number, addOrUpdate) {
        $('#createTestPaper').fadeIn(1500);
        if (number == "1") {
            $('#createPaperTitles').html(' 创建普通试卷&nbsp;&nbsp;&nbsp;<small style="font-size: 13px;">每个考生的试卷为相同试题，试题在考试时可随机排序显示</small>');
            $('#createTestPaper form').attr('id', 'createTestPaper_1')
        } else {
            $('#createPaperTitles').html(' 创建随机试卷&nbsp;&nbsp;&nbsp;<small style="font-size: 13px;">每个考生的试卷为系统随机生成，考生试卷中的试题各不相同</small>');
            $('#createTestPaper form').attr('id', 'createTestPaper_2')
        }
        $('#topicManagement').fadeOut(500);
        $('#tab-1 button[title="创建试卷"]').attr('class', 'btn btn-success dropdown-toggle')
        $('#tab-1 button[title="试卷管理"]').attr('class', 'btn btn-white dropdown-toggle')
        //回显数据
        if (judging) {
            echoData(parameters);
        } else {
            $("#createTestPaper form")[0].reset();
            $('#createTestPaper form input').css('border-color', "")
            switchery_NoTable.setPosition(false);
            //清空章节内容
            let clone = $('div[panel_sign="0"]:last').clone().css('display', 'block');
            $('#accordion').empty();
            $('#accordion').append(clone);
            panel_sign = 0;
            submitAllChapterData.clear()
            panelMap.clear()
            panelEventMap.clear()
        }
        //如果是更新，则去掉按钮颜色 将添加按钮隐藏 显示修改按钮
        if (addOrUpdate == "update") {
            $('#tab-1 button[title="创建试卷"]').attr('class', 'btn btn-white dropdown-toggle')
            $("#addBtn").hide();
            $("#alertBtn").show();
        } else {
            //清空章节内容
            let clone = $('div[panel_sign="0"]:last').clone().css('display', 'block');
            $('#accordion').empty();
            $('#accordion').append(clone);
            panel_sign = 0;
            submitAllChapterData.clear()
            panelMap.clear()
            panelEventMap.clear()
        }
        //重置属性状态
        judging = false;
        parameters.splice(0, parameters.length);

    }

    function switchover(number) {
        judging = false;
        testPaper(number);
    }

    let parameters = new Array();
    let judging = false;

    //点击添加按钮
    $("#addBtn").click(function () {
        let paperName = $('.createTestPaper input[name="testPaperName_1"]').val();
        let paperType = $('.createTestPaper input[name="classification"]').val();
        checked_notable == true ? paperStatus = 1 : paperStatus = 0;
        $('.createTestPaper input[name="adminPermissions"]').val() == '只读共享' ? paperSecurity = 1 : paperSecurity = 0;
        let paperTotal = $('#createTestPaper input[name=totalScore]').val();
        let topicArr = [];//大题名称的数组
        let arr = [];//大题名称和描述（最后提交给后台的数组）
        let quesArr = [];//小题信息
        for (var [key, val] of submitAllChapterData.entries()) {
            quesArr.push({"key": key, "value": val});
        }
        $('input[name="sectionName"]').each(function (index) {
            topicName = $(this).val();
            if (topicName != '') {
                topicArr.push({"id": index, "topicName": topicName});
            }
        })
        $('input[name="sectionDescription"]').each(function (index) {
            topicDesc = $(this).val();
            $.each(topicArr, function (i, item) {
                if (item.id == index) {
                    arr.push({"id": index, "topicName": item.topicName, "topicDesc": topicDesc})
                }
            })
        })
        //定义json数据
        let json = {
            "examPaper": {
                "paperName": paperName, "paperType": paperType, "paperStatus": paperStatus,
                "paperSecurity": paperSecurity, "paperTotal": paperTotal
            },
            "topicList": arr, "keyAndValueList": quesArr
        };
        //发送ajax请求
        $.ajax({
            type: "POST",
            url: "/owep/examPaper/addPaper",
            data: JSON.stringify(json),
            dataType: "json",
            contentType: "application/json",  //客户端给服务端的格式
            success: function (data) {
                alert(data.msg);
                window.location.reload();
            }
        })
    })

    //点击修改按钮
    $("#alertBtn").click(function () {
        let id = $("#paperId").val();
        let paperName = $('.createTestPaper input[name="testPaperName_1"]').val();
        let paperType = $('.createTestPaper input[name="classification"]').val();
        checked_notable == true ? paperStatus = 1 : paperStatus = 0;
        $('.createTestPaper input[name="adminPermissions"]').val() == '只读共享' ? paperSecurity = 1 : paperSecurity = 0;
        let paperTotal = $('#createTestPaper input[name=totalScore]').val();
        let topicArr = [];//大题名称的数组
        let arr = [];//大题名称和描述（最后提交给后台的数组）
        let quesArr = [];//小题信息
        for (var [key, val] of submitAllChapterData.entries()) {
            quesArr.push({"key": key, "value": val});
        }
        $('input[name="sectionName"]').each(function (index) {
            topicName = $(this).val();
            if (topicName != '') {
                topicArr.push({"id": index, "topicName": topicName});
            }
        })
        $('input[name="sectionDescription"]').each(function (index) {
            topicDesc = $(this).val();
            $.each(topicArr, function (i, item) {
                if (item.id == index) {
                    arr.push({"id": index, "topicName": item.topicName, "topicDesc": topicDesc})
                }
            })
        })
        //定义json数据
        let json = {
            "examPaper": {
                "id": id, "paperName": paperName, "paperType": paperType, "paperStatus": paperStatus,
                "paperSecurity": paperSecurity, "paperTotal": paperTotal
            },
            "topicList": arr, "keyAndValueList": quesArr
        };
        //发送ajax请求
        $.ajax({
            type: "POST",
            url: "/owep/examPaper/alterPaper",
            data: JSON.stringify(json),
            dataType: "json",
            contentType: "application/json",  //客户端给服务端的格式
            success: function (data) {
                alert(data.msg);
                window.location.reload();
            }
        })
    })

    //数据回显
    function echoData(arrayForEvent) {
        //准备数据
        let arrayForValue = new Map();
        let arrayIsNull = new Array();
        if (arrayForEvent.length < 1) {
            return false;
        }
        arrayForEvent.forEach(function (item, index) {
            item.val() != "" ? arrayForValue.set(item, item.val()) : arrayIsNull.push(item);
        })
        //刷新页面
        $("#createTestPaper form")[0].reset();
        //回显数据
        if (arrayForValue.size > 0) {
            arrayForValue.forEach(function (value, key) {
                key.css('border-color') == "#f8ac59" ? key.css('border-color', '') : "";
                key.val(value);
            });
        }
        if (arrayIsNull.length > 0) {
            arrayIsNull.forEach(function (item, index) {

                item.css('border-color', "#f8ac59");

            })
        }
        //清空集合
        arrayForValue.clear();
        arrayIsNull.splice(0, arrayIsNull.length);
    }

    //跳转页面判断
    function pageJudgment(addOrUpdate) {
        $('#createTestPaper form').attr('id') == 'createTestPaper_1' ?
            (addOrUpdate == "update" ? testPaper(1, "update") : testPaper(1, "add")) : (addOrUpdate == "update" ? testPaper(2, "update") : testPaper(2, "add"));
    }

    $('#createTestPaper .reset').click(function () {
        $("#createTestPaper form")[0].reset();
        $('#createTestPaper form input').css('border-color', "")
        switchery_NoTable.setPosition(false);
        //清空章节内容
        let clone = $('div[panel_sign="0"]:last').clone().css('display', 'block');
        $('#accordion').empty();
        $('#accordion').append(clone);
        panel_sign = 0;
        submitAllChapterData.clear()
        panelMap.clear()
        panelEventMap.clear()
    });
    /********************************************END---表单********************************************/
</script>
<!--表格-->
<script>

    /*试卷管理表格*/
    $('.tb_departments').bootstrapTable({
        url: '/owep/examPaper/findAllPaper',
        // method: 'get',
        toolbar: '#toolbar',
        striped: true,
        cache: false,
        pagination: true,
        pageNumber: 1,
        pageSize: 5,
        pageList: [5, 15, 20, 25],
        uniqueId: "id",
        onPostBody: switchForTable,
        columns:
            [{
                checkbox: true
            }, {
                field: 'id',
                visible: false
            }, {
                title: '试卷名称',
                formatter: testPaperName
            }, {
                title: '引用次数',
                formatter: citations,
                events: {
                    'click a[title=点我查看详情]': function (e, value, row, index) {
                        $('#modal_2 .testPaperName_2').text(row.paperName);
                        $('#modal_2').modal();
                    }
                }
            }, {
                title: '状态',
                formatter: state
            }, {
                title: '类型',
                formatter: type,
            }, {
                field: 'paperType',
                title: '分类'
            }, {
                title: '总分',
                formatter: totalScore
            }, {
                title: '管理权限',
                formatter: adminPermissions
            }, {
                title: '最后修改',
                formatter: lastModified
            }, {
                title: '操作',
                formatter: operation,
                events: {
                    /*查看*/
                    'click button[title=查看]': detailedTestPaper,  /*END--查看*/
                    /*修改*/
                    'click button[title=修改]': function (e, value, row, index) {
                        if (row.trySorting == "固定排序") {
                            testPaper(1, "update");
                        } else {
                            testPaper(2, "update");
                        }
                        let echoDataList = new Array();
                        echoDataList.push(["testPaperName_1", row.paperName], [switchery_NoTable, row.paperStatus, "sweetalert"], row.paperType, row.paperSecurity);
                        echoDataForm('.createTestPaper', echoDataList, row);
                        //获取数据进行回显
                        $("#paperId").val(row.id);
                        $('.createTestPaper input[name="testPaperName_1"]').val(row.paperName);
                        $('.createTestPaper input[name="classification"]').val(row.paperType);
                        if (row.paperStatus = 1) $('.createTestPaper input[name="startUsing"]').attr('checked', 'checked');
                        row.paperSecurity = 1 ? $('.createTestPaper input[name="adminPermissions"]').val('只读共享') : $('.createTestPaper input[name="adminPermissions"]').val('完全私有');
                        getAjaxAsynchronousData('/owep/examPaper/findPaperById?id=' + row.id, 'get', function (result) {
                            $.each(result[0].examPaperTopics, function (index, item) {
                                index > 0 ? clonePanel() : "";
                                let parent = $('#accordion div[panel_sign=' + index + ']');
                                parent.find('input[name=sectionName]').val(item["topicName"]);
                                parent.find('input[name=sectionDescription]').val(item["topicDesc"]);

                                //所有小题
                                let testQuestions = result[0].examPaperTopicQuessets;
                                //大题对应的小题
                                let topicQues = [];
                                //小题的信息
                                let quesInf = [];
                                //小题在大题中的序号
                                let quesOrder = 0;
                                $.each(testQuestions, function (i, ques) {
                                    if (ques.topicId == item.id) {
                                        topicQues.push({
                                            "id": quesOrder, "title": ques.quesContent, "score": ques.score,
                                            "testQuestionsId": ques.examQues.id
                                        });
                                        quesOrder++;
                                        quesInf.push({
                                            "id": ques.examQues.id,
                                            "typeName": ques.examQues.typeName,
                                            "hardLevel": ques.examQues.hardLevel,
                                            "examBankName": ques.examQues.examBank.bankName,
                                            "lable": ques.examQues.lable,
                                            "status": ques.examQues.status,
                                            "quesContent": ques.examQues.quesContent,
                                            "correctAnswer": ques.examQues.correctAnswer,
                                            "analyze": ques.examQues.analyze
                                        });
                                    }
                                })
                                panelMap.set("" + index, quesInf);
                                submitAllChapterData.set("" + index, topicQues);

                                //遍历展示
                                showChapterTopic("" + index, submitAllChapterData);
                            })
                        })
                        judging = false;
                    },  /*END--修改*/
                    /*删除*/
                    'click button[title=删除]': function (e, value, row, index) {
                        deleteRecord(e, value, row, index, "", '.tb_departments');
                    },  /*END--删除*/
                }
            }]
    });

    /*查看试卷的方法*/
    function detailedTestPaper(e, value, row, index) {
        $('#modal_1 .testPaperName_1').val(row.paperName);
        row.paperStatus == "0" ? $('#modal_1 .state_1').attr("class", 'form-control state_1 text-danger') :
            $('#modal_1 .state_1').attr('class', 'form-control state_1 text-success');
        row.paperStatus == "1" ? $('#modal_1 .state_1').val("可以使用") : $('#modal_1 .state_1').val("禁用");
        if (row.adminPermissions == '0') {
            $('#modal_1 .adminPermissions_1').val("完全私有(只有您本人可以管理和使用该试卷)");
        } else {
            $('#modal_1 .adminPermissions_1').val("只读共享(其他管理员可以浏览和引用该试卷进行考试)");
        }
        $('#modal_1 .totalScore').val(row.paperTotal);

        //每次点击把之前的清空
        var temp = '';
        $("#content").empty();
        //遍历这一行的大题集合
        $.each(row.examPaperTopics, function (i, item) {
            temp = '                      <div class="panel panel-default">\n' +
                '                                <div class="panel-heading">\n' +
                '                                    <strong>章节名称：</strong><a class="nameSection">' + item.topicName + '</a>\n' +
                '                                </div>\n' +
                '                                <table class="table table-bordered">\n' +
                '                                    <tr>\n' +
                '                                        <td>题库</td>\n' +
                '                                        <td>题型</td>\n' +
                '                                        <td>难度</td>\n' +
                '                                        <td>题目</td>\n' +
                '                                        <td>单题分值</td>\n' +
                '                                    </tr>\n' +
                '                                    <tbody id="tb">\n';
            //遍历这一行的小题集合
            $.each(row.examPaperTopicQuessets, function (i, ques) {
                //判断小题中大题的id与正在遍历的大题id是否一致
                if (item.id == ques.topicId) {
                    //将小题拼接到对应的大题下
                    temp += '<tr>\n';
                    temp += '<td>' + ques.examQues.examBank.bankName + '</td> ' +
                        '<td>' + ques.examQues.typeName + '</td> ' +
                        '<td>' + ques.examQues.hardLevel + '</td> ' +
                        '<td>' + ques.quesContent + '</td> ' +
                        '<td>' + ques.score + '</td>'
                    temp += '</tr>\n';
                }
            })
            temp += '                                    </tbody>\n' +
                '                                </table>\n' +
                '                            </div>\n';
            //追加
            $("#content").append(temp);
        })
        $('#modal_1').modal();

    }

    /*共享试卷表格*/
    $('.tb_departments_1').bootstrapTable({
        url: '../../static/js/demo/exam/testQuestionsListTest.json',
        // method: 'get',
        toolbar: '#toolbar_1',
        striped: true,
        cache: false,
        pagination: true,
        pageNumber: 1,
        pageSize: 5,
        pageList: [10, 25, 50, 100],
        uniqueId: "id",
        onPostBody: switchForTable_1,
        columns:
            [{
                checkbox: true
            }, {
                title: '试卷名称',
                formatter: testPaperName
            }, {
                title: '引用次数',
                formatter: citations,
                events: {
                    'click a[title=点我查看详情]': function (e, value, row, index) {
                        $('#modal_2').modal();
                    }
                }
            }, {
                title: '状态',
                formatter: state_1
            }, {
                title: '类型',
                formatter: type,
            }, {
                field: 'classification',
                title: '分类'
            }, {
                title: '总分',
                formatter: totalScore
            }, {
                title: '管理权限',
                formatter: adminPermissions
            }, {
                title: '最后修改',
                formatter: lastModified
            }, {
                title: '操作',
                formatter: operation_1,
                events: {
                    /*查看*/
                    'click button[title=查看]': detailedTestPaper,  /*END--查看*/
                }
            }]
    });

    /*关联的考试表格*/
    $('.tb_departments_2').bootstrapTable({
        url: '../../static/js/demo/exam/testQuestionsListTest.json',
        // method: 'get',
        striped: true,
        cache: false,
        pagination: true,
        pageNumber: 1,
        pageSize: 5,
        pageList: [10, 25, 50, 100],
        uniqueId: "id",
        columns:
            [{
                checkbox: true
            }, {
                title: '试卷名称',
                formatter: testPaperName
            }, {
                title: '考试时间',
                formatter: citations
            }, {
                title: '总分',
                formatter: totalScore
            }, {
                title: '创建人',
                field: "modifier"
            }]
    });

    /***********************************************参数个性化********************************************/
    //试卷名称
    function testPaperName(value, row, index) {
        return '<span><i class="glyphicon glyphicon-list-alt"></i>&nbsp;&nbsp;' + row.paperName + '</span>';
    }

    //引用次数
    function citations(value, row, index) {
        return '<strong><a class="text-success ' + row.id + '" style="font-size:20px;" title="点我查看详情">' + 0 + '</a></strong>次';
    }

    //状态(我的试卷)
    function state(value, row, index) {
        return row.paperStatus == '1' ? ' <input type="checkbox" class="js-switch-table-state form-control" checked/>' :
            ' <input type="checkbox" class="js-switch-table-state form-control"/>'
    }

    //状态(共享试卷)
    function state_1(value, row, index) {
        return row.paperSecurity == '1' ? ' <input type="checkbox" class="js-switch-table-state_1 form-control" checked/>' :
            ' <input type="checkbox" class="js-switch-table-state_1 form-control"/>'
    }

    //类型
    function type(value, row, index) {
        return row.paperSecurity == '1' ? '<i class="glyphicon glyphicon-random"></i>' : '<i class="glyphicon glyphicon-tasks"></i>';
    }

    //总分
    function totalScore(value, row, index) {
        return row.paperTotal >= 80 ? '<strong><a href="#" class="text-success" style="font-size:20px;">' + row.paperTotal + '</a></strong>' :
            row.paperTotal >= 60 ? '<strong><a href="#" class="text-warning" style="font-size:20px;">' + row.paperTotal + '</a></strong>' :
                '<strong><a href="#" class="text-danger" style="font-size:20px;">' + row.paperTotal + '</a></strong>';
    }

    //管理权限
    function adminPermissions(value, row, index) {
        return row.paperSecurity == '0' ? '<a class="text-muted"><i class="glyphicon glyphicon-eye-close"></i>&nbsp;&nbsp;完全私有</a>' :
            '<a class="text-success"><i class="glyphicon glyphicon-eye-open"></i>&nbsp;&nbsp;<strong>只读共享</strong></a>';
    }

    //最后修改
    function lastModified(value, row, index) {
        return '<strong><p>' + row.userName + '</p></strong><p>' + row.lastAccessTime + '</P>';
    }

    //操作
    function operation(value, row, index) {
        return '<button id = "+id+" type = "button" class = "btn btn-white" title="查看"> <i class="glyphicon glyphicon-eye-open"/> </button>' +
            '<button id = "+id+" type = "button" class = "btn btn-white" title="修改"> <i class="glyphicon glyphicon-edit text-success"/> </button>' +
            '<button id = "+id+" type = "button" class = "btn btn-white" title="删除"> <i class="glyphicon glyphicon-trash text-danger"/> </button>';
    }

    //操作
    function operation_1(value, row, index) {
        return '<button id = "+id+" type = "button" class = "btn btn-white" title="查看"> <i class="glyphicon glyphicon-eye-open"/> </button>'
    }

    //初始化滑动按钮状态(我的试卷)
    function switchForTable() {
        let elems = Array.prototype.slice.call($('.js-switch-table-state'));
        elems.forEach(function (html) {
            /* size: 'normal' 控制大小*/
            let switchery = new Switchery(html);
            html.onchange = function () {
                alert(html.checked);
            }
        });
    }

    //初始化滑动按钮状态(共享试卷)
    function switchForTable_1() {
        let elems = Array.prototype.slice.call($('.js-switch-table-state_1'));
        elems.forEach(function (html) {
            /* size: 'normal' 控制大小*/
            let switchery = new Switchery(html);
            html.onchange = function () {
                alert(html.checked);
            }
        });
    }

    /*******************************************END---参数个性化********************************************/
    /*END--题库管理表格*/
</script>
</html>